﻿using Architecture.API.Application.TraceabilityCommand.ShoppingCommand;
using MediatR;
using Traceability.Domain;
using Traceability.Domain.Service.ShoppingServices;
using Traceability.Domain.TraceabilityDto;

namespace Architecture.API.Application.TraceabilityCommandHandler.ShoppingCommandHandler
{
    /// <summary>
    /// 
    /// </summary>
    public class ShoppingSeachCommandHandler : IRequestHandler<ShoppingSeachCommand, ShoppingPaginationDto<ShowShoppingDto>>
    {
        /// <summary>
        /// 商品服务
        /// </summary>
        protected readonly IShoppingService shoppingService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="shoppingService">商品服务</param>
        public ShoppingSeachCommandHandler(IShoppingService shoppingService)
        {
            this.shoppingService = shoppingService;
        }

        /// <summary>
        /// 获取商品列表
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken">取消标记</param>
        /// <returns>返回商品列表</returns>
        public async Task<ShoppingPaginationDto<ShowShoppingDto>> Handle(ShoppingSeachCommand request, CancellationToken cancellationToken)
        {
            return await shoppingService.GetShopping(request.pageIndex,request.pageSize);
        }
    }
}
